package com.car.order.controller;

import com.car.commons.core.model.Result;
import com.car.order.entity.ServiceOrderProcess;
import com.car.order.entity.form.serveOrderProcess.ServiceOrderProcessFindListForm;
import com.car.order.entity.form.serveOrderProcess.ServiceOrderProcessFindPageForm;
import com.car.order.entity.form.serveOrderProcess.ServiceOrderProcessInsertForm;
import com.car.order.entity.form.serveOrderProcess.ServiceOrderProcessUpdateForm;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

import org.springframework.web.bind.annotation.*;
import com.car.order.service.ServiceOrderProcessService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;

/**
 *
 *
 * @author 杜岷芫
 * @since 2024-08-29 11:30:53
 */
@RestController
@RequestMapping("/serviceOrderProcess")
@Api(tags = "服务进程信息")
public class ServiceOrderProcessController {

    @Autowired
    private ServiceOrderProcessService serviceOrderProcessService;

    /**
     * 分页查询
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody ServiceOrderProcessFindPageForm form) {
        Page<ServiceOrderProcess> result = serviceOrderProcessService.findPage(form);
        return Result.getResult().setMsg("查询成功").setData(result);
    }
    /**
     * 列表查询
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "列表查询")
    @PostMapping("/findList")
    public Result findList(@RequestBody ServiceOrderProcessFindListForm form) {
        List<ServiceOrderProcess> result = serviceOrderProcessService.findList(form);
        return Result.getResult().setMsg("查询成功").setData(result);
    }

    /**
     * 查询
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id查询详情")
    @GetMapping("/{id}")
    public Result findById(@PathVariable("id") Integer id) {
        ServiceOrderProcess serviceOrderProcess = serviceOrderProcessService.findById(id);
        return Result.getResult().setMsg("查询成功").setData(serviceOrderProcess);
    }

    /**
     * 新增
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "新增")
    @PostMapping
    public Result insert( @RequestBody ServiceOrderProcessInsertForm form) {
        ServiceOrderProcess serviceOrderProcess = serviceOrderProcessService.insert(form);
        return Result.getResult().setMsg("操作成功").setData(serviceOrderProcess);
    }

    /**
     * 修改
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "修改")
    @PutMapping
    public Result update( @RequestBody ServiceOrderProcessUpdateForm form) {
        ServiceOrderProcess serviceOrderProcess = serviceOrderProcessService.update(form);
        return Result.getResult().setMsg("操作成功").setData(serviceOrderProcess);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") Integer id) {
        serviceOrderProcessService.delete(id);
        return Result.getResult().setMsg("操作成功");
    }

}